package com.winit.schedule.job.tracker.repository.mysql.dao;

import java.util.List;

import com.winit.schedule.core.repository.entity.TaskTrackerEntity;
import com.winit.schedule.core.repository.query.TaskTrackerQuery;
import com.winit.schedule.job.tracker.repository.mysql.plugin.SearchRequest;

public interface MysqlTaskTrackerDao {

    void saveTaskTracker(TaskTrackerEntity entity);

    void updateTaskTracker(TaskTrackerEntity entity);

    TaskTrackerEntity getTaskTrackerByUuid(String taskTrackerUuid);

    void removeTaskTracker(String taskTrackerUuid);

    void updateHeartbeatTime(TaskTrackerEntity entity);

    /**
     * 删除已经超时的taskTracker信息
     * 
     * @param timeout 最接近超时的时间，心跳时间小于等于timeout都表示为超时
     */
    void removeTaskTrackerForTimeout(long timeout);

    List<TaskTrackerEntity> queryTaskTrackerForTimeout(long timeout);

    List<TaskTrackerEntity> findTaskTrackerPage(SearchRequest<TaskTrackerQuery> search);

    long findTaskTrackerPageCount(TaskTrackerQuery query);

    /**
     * 根据任务定义信息查询tasktracker
     * 
     * @param taskGroup
     * @param taskName
     * @return
     */
    List<TaskTrackerEntity> findTaskTrackerByTask(TaskTrackerQuery query);

    /**
     * 根据任务ID查询活动的TaskTracker数量
     * 
     * @param taskId
     * @return
     */
    long queryTaskTackerNumberByTaskId(String taskGroup, String taskName);

}
